package com.add;

import com.lineage.DatabaseFactory;
import com.lineage.server.utils.SQLUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class L1ResetMapTime {
  private static final Log _log = LogFactory.getLog(L1ResetMapTime.class);
  
  private static L1ResetMapTime _instance;
  
  public static L1ResetMapTime get() {
    if (_instance == null)
      _instance = new L1ResetMapTime(); 
    return _instance;
  }
  
  private void updateResetMapTime(int id, Calendar reset_cal) {
    Connection con = null;
    PreparedStatement pstm = null;
    try {
      con = DatabaseFactory.get().getConnection();
      pstm = con.prepareStatement("UPDATE `config_other` SET `resetMaptime`=? WHERE `id`=?");
      SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      String fm = sdf.format(reset_cal.getTime());
      int i = 0;
      pstm.setString(++i, fm);
      pstm.setInt(++i, id);
      pstm.execute();
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } finally {
      SQLUtil.close(pstm);
      SQLUtil.close(con);
    } 
  }
}
